﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Pavilion.DesignerTool
{
    class TrackedNodeScript
    {
        private ResourceItem parentResource;
        private NodeScript nodeScript;
        private TrackedContainerNode trackedRootContainer;
        private string originalName;

        public TrackedNodeScript(ResourceItem parentResource, NodeScript nodeScript)
        {
            this.parentResource = parentResource;
            this.nodeScript = nodeScript;
            this.originalName = nodeScript.Name;

            trackedRootContainer = new TrackedContainerNode(nodeScript.RootContainer, nodeScript, parentResource);
        }

        public void TransferData()
        {
            if (nodeScript.Name != originalName)
                NodeScriptTransfer.Rename(parentResource.Name, originalName, nodeScript.Name);

            trackedRootContainer.TransferDataReorder();
            trackedRootContainer.TransferDataUpdate();
        }
    }
}
